package xdu.lz.stage2_design_pattern.chapter4_shared_resource_pattern;


//一个使用资源的线程
public class User extends Thread {
    private final String myName;
    private final String myAddress;
    private final Gate gate;

    public User(String myName, String myAddress, Gate gate) {
        this.myName = myName;
        this.myAddress = myAddress;
        this.gate = gate;
    }

    @Override
    public void run() {
        System.out.println(myName + " begin");
        while (true){
            //线程不断使用该资源
            this.gate.pass(myName,myAddress);
        }
    }
}
